import Vue from 'vue';
import Vuex from 'vuex';
import * as getters from './getters'
import ls from '../utils/LocalStorageUtils'

Vue.use(Vuex);
const state = {
  count: 0,
  user:{
    name:''
  }
};

const mutations = {
  increment(state, payload) {
    state.count += payload.amount;
  },
  decrement(state) {
    state.count--
  },
  setUserName(state,payload){
    state.user.name = payload.name;
    ls.setItem('user.name',payload.name)
  }
};

const  store = new Vuex.Store({
  getters,
  state,
  mutations,
  strict: process.env.NODE_ENV !== 'production'
});
store.commit('setUserName',{
  name:ls.getItem('user.name')
})
export default store
